import java.util.Locale;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-03-12
 * Time: 15:09
 */
class Solution {
    private boolean ismyChar(char ch) {
        if (ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9') {
            return true;
        }
        return false;
    }

    public boolean isPalindrome(String s) {
        String str = s.toLowerCase();
        int left = 0;
        int right = str.length() - 1;
        while (left < right) {
            while (left < right && !ismyChar(str.charAt(left))) {
                //如果left下标不是合法字符,left++
                left++;
            }
            while (left < right && !ismyChar(str.charAt(right))) {
                //如果right下标不是合法字符,right++
                right--;
            }
            if (str.charAt(left)==str.charAt(right)) {
                left++;
                right--;
            } else {
                return false;
            }
        }
        return true;
    }
}